/**
 * Copyright (c) Enalean, 2017 - 2018. All Rights Reserved.
 *
 * This file is a part of Tuleap.
 *
 * Tuleap is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * Tuleap is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Tuleap. If not, see <http://www.gnu.org/licenses/>.
 */

$tlp-spacing: 20px;
$step-background: $white;
$step-color: #838487;
$step-border: #e3e3e3;
$step-border-chevron: #d5d5d5;
$step-active-color: $main;
$step-active-border: transparentize($main, .5);
$step-clicked-background: $main;
$step-clicked-border: $main;
$step-clicked-color: $white;

$switch-menu-background: $step-background;
$switch-menu-border: $step-border;
$switch-menu-item-color: $step-color;
$switch-menu-item-hover-background: $light-grey;
$switch-menu-item-hover-color: $step-active-color;
$switch-menu-item-active-background: $step-active-color;
$switch-menu-item-active-color: $step-clicked-color;

@keyframes menuIn {
    from {
        z-index: -1;
        transform: translate3d(0, -10%, 0);
        opacity: 0;
    }

    to {
        z-index: 0;
        transform: none;
        opacity: 1;
    }
}

.breadcrumb {
    display: flex;
    padding: 12px;
}

.breadcrumb-item {
    display: inline-block;
    position: relative;
    float: left;

    &:first-child > .breadcrumb-link {
        padding-left: $tlp-spacing;
    }

    &:last-child > .breadcrumb-link {
        border: 1px solid $step-active-border;
        color: $step-active-color;
        font-weight: 600;

        &::after {
            box-shadow: 1.5px 1.5px 0 $step-active-border;
        }
    }

    &:hover > .breadcrumb-link {
        border: 1px solid $step-active-border;
        color: $step-active-color;

        &::after {
            box-shadow: 1.5px 1.5px 0 $step-active-border;
        }

        &:active {
            border: 1px solid $step-clicked-border;
            background: $step-clicked-background;
            color: $step-clicked-color;

            &::after {
                background: $step-clicked-background;
                box-shadow: 1.5px 1.5px 0 $step-clicked-border;
            }
        }
    }
}

.breadcrumb-link {
    position: relative;
    padding: 0 10px 0 30px;
    float: left;
    border: 1px solid $step-border;
    background: $step-background;
    color: $step-color;
    font-size: 13px;
    line-height: 33px;

    &:hover {
        text-decoration: none;
    }

    &::after {
        content: '';
        position: absolute;
        z-index: 1;
        top: 0;
        right: -16px;
        width: 33px;
        height: 33px;
        transform: rotate(-45deg) scale(.73);
        transition: box-shadow 150ms;
        border-radius: 50px 0 0;
        background: $step-background;
        box-shadow: 1.5px 1.5px 0 $step-border-chevron;
    }
}

.breadcrumb-link-icon {
    margin: 0 5px 0 0;
}

.breadcrumb-switchable {
    display: inline-block;
    position: relative;

    > .breadcrumb-link {
        padding: 0 $tlp-spacing 0 30px;
    }

    &::after {
        content: '\f0d7'; // icon-caret-down
        position: absolute;
        z-index: 1;
        top: 8px;
        right: 7px;
        transition: opacity 100ms;
        opacity: .25;
        color: $step-color;
        font-family: 'FontAwesome';
        font-size: 10px;
    }

    &:hover {
        > .breadcrumb-switch-menu {
            display: inline-block;
            z-index: 1;
            animation: 100ms menuIn;
        }

        &::after {
            opacity: 1;
            color: $step-active-color;
        }
    }
}

.breadcrumb-switch-menu {
    display: none;
    position: absolute;
    top: 35px;
    left: 0;
    min-width: 100%;
    max-width: 150%;
    padding: 0;
    border: 1px solid $switch-menu-border;
    border-top: 0;
    border-radius: 0 0 3px 3px;
    background: $switch-menu-background;
    box-shadow: 0 8px 30px rgba(0, 0, 0, .05);
}

.breadcrumb-dropdown-item {
    &:hover > .breadcrumb-dropdown-link {
        background: $switch-menu-item-hover-background;
        color: $switch-menu-item-hover-color;

        &:active {
            background: $switch-menu-item-active-background;
            color: $switch-menu-item-active-color;
        }
    }

    &:last-child > .breadcrumb-dropdown-link {
        border-radius: 0 0 3px 3px;
    }
}

.breadcrumb-dropdown-link {
    display: block;
    padding: 0 15px;
    overflow: hidden;
    color: $switch-menu-item-color;
    font-size: 12px;
    line-height: 30px;
    text-overflow: ellipsis;
    white-space: nowrap;

    &:hover {
        text-decoration: none;
    }
}

.breadcrumb-separator {
    height: 1px;
    margin: 10px 0;
    background: $switch-menu-border;
}

.breadcrumb-subtitle {
    padding: 0 15px 5px;
    color: $switch-menu-item-color;
    font-size: 12px;
    font-weight: 600;
    line-height: 30px;
    text-transform: uppercase;
    white-space: nowrap;
}
